<?php
$title = '订阅与用户';
/** @var array $subscriptions */
require __DIR__ . '/../partials/head.php';
require __DIR__ . '/../partials/nav.php';
?>
<section class="section">
    <div class="app-container">
        <div class="card" style="gap:18px;">
            <h2 style="margin:0;">订阅总览</h2>
            <table class="table">
                <thead>
                <tr>
                    <th>用户</th>
                    <th>策略</th>
                    <th>启用</th>
                    <th>额度</th>
                    <th>状态</th>
                </tr>
                </thead>
                <tbody>
                <?php foreach ($subscriptions as $item): ?>
                    <tr>
                        <td><?= htmlspecialchars($item['user_email']) ?></td>
                        <td><?= htmlspecialchars($item['script_code']) ?></td>
                        <td><?= $item['enabled'] ? '是' : '否' ?></td>
                        <td><?= htmlspecialchars((string)($item['allocation']['value'] ?? '-')) ?></td>
                        <td><?= htmlspecialchars($item['status']) ?></td>
                    </tr>
                <?php endforeach; ?>
                </tbody>
            </table>
            <?php if (empty($subscriptions)): ?>
                <div class="empty-state">
                    <img src="/assets/img/empty/strategies.svg" alt="暂无订阅">
                    <p>还没有用户订阅策略。</p>
                </div>
            <?php endif; ?>
        </div>
    </div>
</section>
<?php require __DIR__ . '/../partials/footer.php'; ?>
